package keke.ai.code.mother.util;

import jakarta.annotation.Resource;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

@Component
public class PwdEncyptUtil {


    public static String encyptPwdMD5(String pwd) {
        return DigestUtils.md5DigestAsHex(pwd.getBytes());
    }


    public static String encyptPwdBCrypt(String pwd) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        String encode = bCryptPasswordEncoder.encode(pwd);
        return encode;
    }

    public static void main(String[] args) {
        System.out.println(encyptPwdBCrypt("123456"));
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        boolean matches = passwordEncoder.matches("123456", "$2a$10$/55vp/QmKitxdIbhIY0H/ep.enJN.tKEz12RQbpdBh46.Duhkvh7a");
        System.out.println(matches);
    }
}
